
uniform sampler2D		bumpMap;
uniform samplerCube	environmentMap;

uniform vec4		environmentColor;

varying vec3		viewVector;
varying vec2		bumpTexCoord;
varying mat3		tangentToGlobal;
varying vec4		vertexColor;


void main (void){

	vec4		color;
	vec3		viewVec, normalVec, reflectionVec;

	// Normalize the view vector
	viewVec = normalize(viewVector);

	// Load the normal vector from the bump map
	normalVec = texture2D(bumpMap, bumpTexCoord).rgb * 2.0 - 1.0;
	normalVec = normalize(normalVec);

	// Compute the reflection vector and transform into global space
	reflectionVec = reflect(-viewVec, normalVec) * tangentToGlobal;

	// Modulate the environment map by the environment color
	color = textureCube(environmentMap, reflectionVec) * environmentColor;

	// Modulate by the vertex color
	gl_FragColor = color * vertexColor;
}
